<?php

namespace App\Admin\Forms;

use Dcat\Admin\Widgets\Form;

class SettingForm extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        admin_setting($input);
        return $this
				->response()
				->success('Processed successfully.')
				->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->text('title', trans('网页title'))->default(admin_setting('title'));
        $this->text('name', trans('网站名称'))->default(admin_setting('name'));
        $this->text('url', trans('域名'))->default(admin_setting('url', 'http://nounhappy.com'));
        $this->text('version', trans('版本'))->default(admin_setting('version', '1.0.0'));
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function defaults()
    {
        return [
            'title' => '社区助手',
            'name'  => '社区助手',
        ];
    }
}
